package com.example.controller;

import com.example.pojo.entity.Comment;
import com.example.service.CommentService;
import com.example.util.OrderNumUtil;
import com.example.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 本文来演示
 *
 * @author 赵建云
 * @create 2023/10/21
 */
@RestController
@RequestMapping("comment")
public class CommentController {
    @Autowired
    private CommentService commentService;
    @PostMapping("searchComment")
    public Result searchComment(String problemId) {
        List<Comment> list = commentService.findByProblemId(problemId);
        return new Result(200,"该问题下的所有评论",list);
    }
    @PostMapping("saveComment")
    public Result saveComment(Integer jsId,String problemId,String comment){
        System.out.println(jsId+":"+problemId+":"+comment);
        int count = commentService.saveComment(jsId,problemId,comment);
        return new Result(200,"评论成功");
    }
    @PostMapping("addCommentLikeNum")
    public Result addCommentLikeNum(Integer jsId,String commentId){
        int count = commentService.addCommentLikeNum(jsId,commentId);
        return new Result(200,"评论点赞成功");
    }


}
